(function (jQuery) {
    jQuery (function ($) {
        window.FeedbackPage = Spine.Controller.sub();
        window.LoginRegisterPage = Spine.Controller.sub();
        window.Search = Spine.Controller.sub();
        window.Settings = Spine.Controller.sub();
        window.Viewer = Spine.Controller.sub();
        window.ViewOrder = Spine.Controller.sub();
        window.MakeOrder = Spine.Controller.sub();
        window.Editor = Spine.Controller.sub();
        window.App = Spine.Controller.create({
            el: $("body"),
            elements: {
                "#control-panel": "controlPanelEl",
                "#profile-page": "profileEl",
                "#editor-page": "editorEl",
                "#settings-page": "settingsEl",
                "#collection-page": "searchEl",
                "#make-order-page": "makeOrderEl",
                "#view-order-page": "viewOrderEl",
                "#viewer-page": "viewerEl",
                "#feedback-page": "feedbackEl",
                "#login-register-page": "loginRegisterEl",
                "#body": "bodyEl"
            },
            init: function () {
                this.profile = new ProfileModule.Profile({ el: this.profileEl });
                this.editor = new Editor({ el: this.editorEl });
                this.settings = new Settings({ el: this.settingsEl });
                this.search = new Search({ el: this.searchEl });
                this.makeOrder = new MakeOrder({ el: this.makeOrderEl });
                this.viewOrder = new ViewOrder({ el: this.viewOrderEl });
                this.viewer = new Viewer({ el: this.viewerEl });
                this.feedback = new FeedbackPage({ el: this.feedbackEl });
                this.loginRegister = new LoginRegisterPage({ el: this.loginRegisterEl });
                this.Pages = new Spine.Manager(
                    this.editor,
                    this.search,
                    this.profile,
                    this.settings,
                    this.feedback,
                    this.loginRegister,
                    this.makeOrder,
                    this.viewOrder,
                    this.viewer
                );
                this.controlPanel = new ControlPanel({
                    el: this.controlPanelEl,
                    eventsMngr: this.appEvents,
                    newProjectPage: this.editor,
                    searchPage: this.search,
                    profilePage: this.profile,
                    settingsPage: this.settings,
                    feedbackPage: this.feedback,
                    loginRegisterPage: this.loginRegister
                });
                this.editor.active();
            }
        });
        window.app = new App();
    });
})(jQuery);